package net.huashitong.Indicators.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.Indicators.entity.AppMsgGroup;
import net.huashitong.Indicators.filter.AppMessageFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class AppMsgGroupDao extends StringDao<AppMsgGroup> {

    public List<AppMsgGroup> queryByOrderCreateDate(){
        GenericQuery query = createQuery("obj");
        query.append("  order By obj.createDate desc");
        return query.listResult();
    }

    public List<AppMsgGroup> queryByFilter(AppMessageFilter filter){
        GenericQuery query = createQuery("obj");
        if(StringUtils.isNotBlank(filter.getOpenId())){
            query.append(" and obj.openId=:openId").setParam("openId", filter.getOpenId());
        }
        return query.listResult();
    }

}
